import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.io.IOException;
import java.io.PrintWriter;

@WebServlet(name = "GetServlet", value = "/GetServlet")
public class GetServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        request.setCharacterEncoding("utf-8");
        response.setContentType("text/html;charset=UTF-8");
        PrintWriter out = response.getWriter();
        String book = request.getParameter("book");
        String name = request.getParameter("name");
        if (book.equals("科技")){
            request.setAttribute("name",name);
            RequestDispatcher rd = request.getRequestDispatcher("/ScienceServlet");
            rd.forward(request,response);
        } else {
            out.println("2021132323，请多关注科技的发展");
        }
    }
    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doGet(request,response);
    }
}
